﻿#pragma strict

var state : int;
var RUNNING = 0;
var JUMPING = 1;
var SHOOTING = 2;
var source : Vector3;
var destination : Vector3;
var startTime : float;

function Start () {
	state = RUNNING;
}

function Update () {
	if (state != JUMPING && Input.GetKey("up")) {
		source = transform.position;
		destination = transform.position;
		destination.y += 2;
		Jump();
	}
	if (state == JUMPING) {
		transform.position = Vector3.Lerp(source,destination,(Time.time - startTime)*3f);
		if (transform.position == destination) {
			source = transform.position;
			destination = transform.position;
			destination.y -= 2;
		}
	}
}

function Jump () {
	startTime = Time.time;
	state = JUMPING;
	var animator = GetComponent(Animator);
	animator.Play("MegamanJump");
}